{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "\n",
    "from synthetic_datasets import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# exp1: linear  \n",
    "\n",
    "# exp1: d=12, prob=0.5, 'lingam', s=np.ones([d]) (same variance)\n",
    "#       d=12, prob=0.5, 'gaussian', s=np.ones([d]) (same variance)\n",
    "#       d=12, prob=0.5, 'lingam', s=np.round(np.random.uniform(low=0.5, high=2, size=[d]), 1) (same variance)\n",
    "#       d=12, prob=0.5, 'gaussian', s=np.round(np.random.uniform(low=0.5, high=2, size=[d]), 1) (diff. noise variance)\n",
    "#       d=30, prob=0.2, 'gaussian', s=np.ones([d]) (same variance)\n",
    "\n",
    "seeds = [8]\n",
    "\n",
    "for seed in seeds:\n",
    "    np.random.seed(seed)\n",
    "    d = 12\n",
    "    W = generate_W(d=d, prob=0.5) # 0.2 \n",
    "    c = np.zeros(d)\n",
    "    s = np.ones([d]) # s = np.round(np.random.uniform(low=0.5, high=2, size=[d]), 1) different varicne\n",
    "    xs, b_, c_ = gen_data_given_model(W, s, c, n_samples=5000, noise_type='lingam', permutate=True)\n",
    "    \n",
    "# save your data     \n",
    "#     dir_name = os.path.join(os.getcwd(), 'lingam_same_noise_seed{}'.format(seed))\n",
    "#     os.mkdir(dir_name)   \n",
    "#     np.save(os.path.join(dir_name, 'data.npy'), xs)\n",
    "#     np.save(os.path.join(dir_name, 'DAG.npy'), b_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# exp2: quadractiv \n",
    "\n",
    "seeds = [8]\n",
    "for seed in seeds:\n",
    "    np.random.seed(seed)\n",
    "    d = 10\n",
    "    W = generate_W(d=d, prob=0.5)\n",
    "    c = np.zeros(d)\n",
    "    #s = np.round(np.random.uniform(low=0.5, high=2, size=[d]), 1)\n",
    "    s = np.ones([d])\n",
    "    xs, b_, c_ = gen_data_given_model_2nd_order(W, s, c, n_samples=5000, noise_type='lingam', permutate=True)\n",
    "    \n",
    "    # get the first 3000 samples\n",
    "    xs_norm = np.linalg.norm(xs, axis=1)\n",
    "    xs_th = sorted(xs_norm)[3000]\n",
    "    xs = xs[xs_norm < xs_th]\n",
    "    \n",
    "    # save data\n",
    "#     dir_name = os.path.join(os.getcwd(), 'lingam_quad_same_noise_seed{}'.format(seed))\n",
    "#     os.mkdir(dir_name)\n",
    "    \n",
    "#     np.save(os.path.join(dir_name, 'data.npy'), xs)\n",
    "#     np.save(os.path.join(dir_name, 'DAG.npy'), b_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# exp3: gp data\n",
    "\n",
    "The GP datasets can be generated using the R code of the ANM available at http://people.tuebingen.mpg.de/jpeters/onlineCodeANM.zip\n",
    "A python interface is from the GraN-DAG authos, available at datahttps://github.com/kurowasan/GraN-DAG/blob/964b698d49f507eb5d505e4511ed289f9a8ec01b/baselines_and_metrics/rcode/code_GraN-DAG/generateData.R"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
